package transferobject;

import java.io.Serializable;

/**
 * Transfer Object class for Bid
 * @author Ilya_Poliakov
 */
public class Bid implements Serializable {

	/**
	 * Serial version UID
	 */
	private static final long serialVersionUID = -2845686766777847804L;

	/**
	 * Bid value
	 */
	private final float bid;

	/**
	 * Bidder ID
	 */
	private final int bidderId;

	/**
	 * Bid ID
	 */
	private int bidId;

	/**
	 * Bidding item ID
	 */
	private final int itemId;

	/**
	 * Create new Bid object with unassigned ID
	 * @param bid Bid value
	 * @param bidderId Bidder ID
	 * @param itemId Item ID
	 */
	public Bid(int bidderId, float bid, int itemId) {
		this(-1, bidderId, bid, itemId);
	}

	/**
	 * Create new Bid object
	 * @param bidId Bid ID
	 * @param bidderId Bidder ID
	 * @param bid Bid value
	 * @param itemId Item ID
	 */
	public Bid(int bidId, int bidderId, float bid, int itemId) {
		super();
		this.bidId = bidId;
		this.bid = bid;
		this.bidderId = bidderId;
		this.itemId = itemId;
	}

	/**
	 * return the bid
	 * @return the bid
	 */
	public float getBid() {
		return bid;
	}

	/**
	 * return the bidderId
	 * @return the bidderId
	 */
	public int getBidderId() {
		return bidderId;
	}

	/**
	 * return the bidId
	 * @return the bidId
	 */
	public int getBidId() {
		return bidId;
	}

	/**
	 * return the itemId
	 * @return the itemId
	 */
	public int getItemId() {
		return itemId;
	}

	/**
	 * Set the bid ID
	 * @param bidId the bidId to set
	 */
	public void setBidId(int bidId) {
		if (this.bidId != -1)
			throw new IllegalArgumentException("BID id is already binded");
		this.bidId = bidId;
	}

}
